package com.quick.admin.web;

import com.quick.admin.service.PermissionService;
import com.quick.admin.service.RoleService;
import com.quick.admin.service.UserAdminService;
import com.quick.common.dto.UserAdminDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * @author ：chicunxiang
 * @date ：Created in 2021/1/28 10:50
 * @description：
 * @version: 1.0
 */
@RestController
@RequestMapping("/admin")
public class FeignController {

    @Autowired
    private RoleService mRoleService;

    @Autowired
    private PermissionService mPermissionService;

    @Autowired
    private UserAdminService mUserAdminService;

    @PostMapping("/queryRoleByIds")
    public Set<String> queryRoleByIds(@RequestBody List<String> roleIdList) {
        return mRoleService.queryByIds(roleIdList);
    }

    @PostMapping("/queryPermissionByRoleIds")
    public Set<String> queryPermissionByRoleIds(@RequestBody List<String> roleIdList) {
        return mPermissionService.queryByRoleIds(roleIdList);
    }

    @GetMapping("/findAdminFromUsername")
    public List<UserAdminDto> findAdminFromUsername(@RequestParam("username") String username) {
        return mUserAdminService.findAdminFromUsername(username);
    }
}
